<template>
  <basic-dialog
    :visible.sync="visible"
    :title="'报价有效期修改记录'"
    :width="'60%'"
    :handleClose="handleCloseDialog"
    :handleOpen="handleOpen"
    :showFooter="false"
  >
    <SkusTable
      :showSelectCol="false"
      :showTotal="false"
      :dataSource="tableInfo.list"
      :columns="columns"
      :loading="tableInfo.loading"
      :tableHeight="400"
    />
  </basic-dialog>
</template>
<script>
import BasicDialog from '@/components/BasicDialog';
import SkusTable from '@/components/skusTable';
import skusPage from '@/mixins/commodity/skusPage';
import {
  getSupplierQuoteExpireTimeRecordService,
} from '@/api/sourcing/public';

export default {
  name: 'EditExpireTime', // 修改报价有效期
  mixins: [skusPage],
  components: {
    BasicDialog,
    SkusTable,
  },
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    sourcingBillId: {
      type: [String, Number],
      required: true,
    },
  },
  data () {
    return {
      columns: [
        {
          key: 'supplierName',
          title: '供应商名称',
        },
        {
          key: 'supplierCode',
          title: '供应商代码',
        },
        {
          key: 'beforeTime',
          title: '报价有效期原值',
        },
        {
          key: 'afterTime',
          title: '报价有效期现值',
        },
        {
          key: 'updateName',
          title: '修改人',
        },
        {
          key: 'updateTime',
          title: '修改时间',
        },
      ]
    };
  },
  methods: {
    handleOpen () {
      this.getTableData()
    },
    // 关闭弹框
    handleCloseDialog () {
      this.$emit('update:visible', false);
    },
    // 提交
    async getTableData () {
      const res = await getSupplierQuoteExpireTimeRecordService({
        sourcingBillId: this.sourcingBillId,
      }, state => { this.tableInfo.loading = state })
      if (res) {
        this.tableInfo.list = res.data
      }
    },
  }
};
</script>
